<include file="Public:header" />
<div class="reg_warp">
    <div class="log_warp_left">
        <p class="log_reg_sm">我还没有我要玩帐号，赶快注册吧！</p>
        <p>
            <button class="public_img log_reg_btn" onclick="register()">立即注册</button>
        </p>
    </div>

    <!---->
    <div class="log_warp_right">
        <h3 class="log_tit">用户登陆</h3>        
        <p>
            <input type="text" class="log_user_inp" placeholder="登陆名" id="username">
        </p>
        <p>
            <input type="password" class="log_pass_inp" placeholder="密码" id="password">
        </p>
        <p class="log_auto_warp">
            <label for="autolog"><a href="#">忘记密码</a>
                <input id="autolog" class="logcheck" type="checkbox" checked="checked">
                </input>
                &nbsp;自动登录 </label>
        </p>
        <p>
            <button class="public_img log_user_btn" onclick="login()">登陆</button>            
        </p>
        <input type="hidden" id="backurl" data-key="<!--{$backurl}-->"/>        
    </div>
</div>
<script type="text/javascript">
    function register() {
        window.location.href = "<!--{:U('user/register')}-->"
    }

    function login() {
        var username = $("#username").val();
            var password = $("#password").val();
            if (username == '') {
                alert("用户名不能为空！");
                return;
            }
            if (password == '') {
                alert("密码不能为空！");
                return;
            }
            var param = 's=user/login&username=' + username + "&password=" + password
            $.ajax({
                type: 'get',
                url: domain + '/index.php',
                data: param,
                dataType: 'jsonp',
                success: function (data) {
                    if(data['ret']==0){                        
                        window.location.href=$("#backurl").attr('data-key');
                    }else{
                        alert(data['msg']);
                    }
                },
                error: function (data) {
                    flag = false;
                    alert('网络忙，请稍后在试！');
                }
            });
    }
</script>
<!---->
<include file="Public:footer" />

